package edu.cs.networkmonitor.scanner;

import java.util.ArrayList;
import java.util.List;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;

import edu.cs.networkmonitor.devices.DeviceSource;

public class DeviceScanner extends BaseScanner {

	public List<DeviceSource> _devices;

	public DeviceScanner() {
		_devices = new ArrayList<DeviceSource>();
	}

	@Override
	public void scan() {
		 PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null);
		 if(printServices != null) {
	       for(PrintService ps : printServices){
	    	   DeviceSource d = new DeviceSource(ps);
	    	   _devices.add(d);
	       }
		 }
	}

    public Object[][] getColumnData() {
        Object[][] data = new Object[_devices.size()][3];
        for (int i = 0; i < _devices.size(); i++) {
            data[i][0] = _devices.get(i).getSourceName();
            data[i][1] = _devices.get(i).getDeviceDescription();
        }
        return data;
    }

    public List<DeviceSource> getSources() {
        return _devices;
    }

}
